import { reqGetOrderTrade,reqSubmitOrder } from "@/api"
const state = {
    orderTrade:{},
    // 商品编号
    orderId:''
}
const actions = {
    // 获取订单页面
    async getOrderTrade({commit}){
        const result = await reqGetOrderTrade()
        if(result.code===200){
            commit('GETORDERTRADE',result.data)
            return 'ok'
        }else return Promise.reject(new Error('fail'))
    },
    // 提交订单
    async submitOrder({commit},params){
        const result = await reqSubmitOrder(params)
        if(result.code===200){
            commit('SUBMITORDER',result.data)
            return 'ok'
        }else return Promise.reject(new Error('fail'))
    }
}
const mutations = {
    GETORDERTRADE(state,orderTrade){
        state.orderTrade = orderTrade
    },
    SUBMITORDER(state,orderId){
        state.orderId = orderId
    }
}
const getters = {}
export default { state, actions, mutations, getters }